<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsp/sys/include.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>"/>
<title>公告管理</title>
<link href="css/global.css" type="text/css" rel="stylesheet"/>

	<link rel="stylesheet" type="text/css" href="css/easydialog.css" />
	<script src="js/easydialog.min.js" type="text/javascript"></script>
	<script src="js/jquery-1.5.1.js" type="text/javascript"></script>
	<script src="js/jquery.form.js" type="text/javascript"></script>
	<script src="js/jquery.validate.js" type="text/javascript"></script>
	<script src="js/jquery.validate.ms.js" type="text/javascript"></script>
	<script src="js/ckeditor/ckeditor.js" type="text/javascript" ></script>


<style type="text/css">
<!--
body{
	background-color:#ffffff;
	margin:0px; padding:0px;
}
label.error{
	font-weight: bold;
	color: red;
}
-->
</style>
</head>

	<body>
	<div id="main">
<input type="button"  value="test" onclick="javascript:alert(document.getElementById('addDataId').innerHTML)"/>
<input type="button"  value="test1" onclick="javascript:alert(document.getElementById('bulState').value)"/>
	<div id="part1" class="part">
		<p class="title"><a href="#">更新公告</a></p>
		<div class="doc" id="doc2">
				<form id="addDataId" action="sysBulletinUpdateAction.do" method="post">
				<ta:formToken/>
				<input type="hidden" name="id" value="${bulletin.id}" />
			
				
				<table>
				<tr><td>标题:<input id="title" name="title" style="width: 270px" type="text" class="txt" value="${bulletin.title}"/></td></tr>
				
				<tr><td>作者:<input id="writer" name="writer" style="width: 270px" type="text" class="txt" value="${bulletin.writer}"/></td></tr>
				<tr><td>状态:<select id="bulState" name="bulState" style="width: 130px">
						<option value="writting" <c:if test="${bulletin.bulState == 'writting'}">selected="selected"</c:if>　>编辑中</option>
						<option value="publishing" <c:if test="${bulletin.bulState == 'publishing'}">selected="selected"</c:if> >已发布</option>
						<option value="cancel" <c:if test="${bulletin.bulState == 'cancel'}">selected="selected"</c:if> >无效</option>
					</select>
					
				</td></tr>
				
				<tr>
				<td>
				
				<textarea cols="80" id="content" name="content" rows="10">${bulletin.content}</textarea>
				
				</td>
				</tr>
				<tr>
				<td>
				<%--
				<input value="提交" type="button" id="submitId" class="btn"/> 
				 --%>
				
				<input value="提交" type="submit" id="sid" class="btn"/>
				
					<input value="重置" type="button" id="resetId" class="btn"/></td>
				</tr>
				</table>	
				
				</form>
		</div>
	</div>
	
	</div>
	</body>
	<script type="text/javascript">
	//
	CKEDITOR.replace('content');


$(document).ready(function(){
	
	var validator = $("#addDataId").validate({
		success: function(label) {
			label.html("<font color='green'>正确！</font>");
		},
		rules: {
			name:{
				required:true
			},
			description:{
				required:true
			}
		}
	});
	
	$('#submitId').click(function(){
			if(true == validator.form()){
				
				// Get the editor instance that you want to interact with.
	var oEditor = CKEDITOR.instances.content;
	$("#content").html(oEditor.getData());
	// Get editor contents
	// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#getData
	//alert( oEditor.getData() );
				
				
				var options = {
					url:'sysBulletinAddAction.do',
					type:'POST',
					success:function(data) {
		         		if("true" == data){
		         			
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据提交成功！',
									yesFn : function(){
		         							//return true;
		         							//window.location="sysRoleQuery.do";
		         							//window.reload();
		         							}
								}
							});
									         			
		         		}else if("repeatSubmit" == data){
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据已提交，请不要重复操作！',
									yesFn : function(){return true;}
								}
							});
		         		}else{
		         			
		         			easyDialog.open({
								container : {
									header : '信息提示',
									content : '数据提交失败！',
									yesFn : function(){return true;}
								}
							});
		         		}
		     		}
				};
				$('#addDataId').ajaxSubmit(options);
				return false;
			}else{
				return false;
			}
	    });

	$("#resetId").click(function() {
        validator.resetForm();
    });
});
</script>
</html>

